package com.leucoderma.medicine.controller;

import com.leucoderma.medicine.pojo.Drugs;
import com.leucoderma.medicine.pojo.Patient;
import com.leucoderma.medicine.service.DrugsService;
import com.leucoderma.medicine.service.PatientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Slf4j
@Controller
public class DrugsController {
    @Autowired
    DrugsService drugsService;

    @ResponseBody
    @PostMapping(value = "/listDrugs")
    List<Drugs> listDrugs(){
        List<Drugs> drugsList = drugsService.listDrugs();
        return drugsList;
    }
    @ResponseBody
    @RequestMapping("/getDrugById")
    Drugs getDrugById(int id){
        return drugsService.getDrugById(id);
    }

    @ResponseBody
    @RequestMapping("/insertNewDrug")
    int insertNewDrug(Drugs drug){
        return drugsService.insertNewDrug(drug);
    }
}
